home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / amsplain.bst < prev    next >
Text File  |  1992-07-19  |  25KB  |  1,198 lines

  1. %%bibtexfile{%
  2. %% filename="amsplain.bst",
  3. %% version="1.1",
  4. %% date="1-JUL-1991",
  5. %% filetype="BibTeX: bibliography style",
  6. %% copyright="Copyright (C) American Mathematical Society, all rights
  7. %%   reserved.  Copying of this file is authorized only if either:
  8. %%   (1) you make absolutely no changes to your copy, including name;
  9. %%   OR (2) if you do make changes, you first rename it to some other
  10. %%   name.",
  11. %% author="American Mathematical Society",
  12. %% address="American Mathematical Society,
  13. %%   Technical Support Group,
  14. %%   P. O. Box 6248,
  15. %%   Providence, RI 02940,
  16. %%   USA",
  17. %% telephone="401-455-4080 or (in the USA) 800-321-4AMS",
  18. %% email="Internet: Tech-Support@Math.AMS.com",
  19. %% checksumtype="line count",
  20. %% checksum="1197",
  21. %% codetable="ISO/ASCII",
  22. %% keywords="latex, amslatex, ams-latex, bibtex",
  23. %% abstract="This file is part of the AMS-\LaTeX{} package, version 1.1.
  24. %%   It is a bibliography style for the BibTeX program that produces
  25. %%   numbered \verb|\bibitem|'s in the style of the primary AMS
  26. %%   journals."
  27. %%}
  28. %%% end of file header
  29. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  30. % BibTeX bibliography style `amsplain'
  31. % version 0.9 for BibTeX versions 0.99a or later, LaTeX version 2.09.
  32. % See the file btxbst.doc for extra documentation other than
  33. % what is included here.  And see btxhak.tex for a description
  34. % of the BibTeX language and how to use it.
  35.  
  36. % This defines the types of fields that can occur in a database entry
  37. % for this particular bibliography style.  Except for `language',
  38. % this is the standard list from plain.bst.
  39.  
  40. %% Types of entries currently allowed in a BibTeX file:
  41. %% 
  42. %% ARTICLE -- An article from a journal or magazine.
  43. %% 
  44. %% BOOK -- A book with an explicit publisher.
  45. %% 
  46. %% BOOKLET -- A work that is printed and bound,
  47. %% but without a named publisher or sponsoring institution.
  48. %% 
  49. %% CONFERENCE -- The same as INPROCEEDINGS,
  50. %% included for Scribe compatibility.
  51. %% 
  52. %% INBOOK -- A part of a book,
  53. %% which may be a chapter (or section or whatever) and/or a range of pages.
  54. %% 
  55. %% INCOLLECTION -- A part of a book having its own title.
  56. %% 
  57. %% INPROCEEDINGS -- An article in a conference proceedings.
  58. %% 
  59. %% MANUAL -- Technical documentation.  
  60. %% 
  61. %% MASTERSTHESIS -- A Master's thesis.
  62. %% 
  63. %% MISC -- Use this type when nothing else fits.
  64. %% 
  65. %% PHDTHESIS -- A PhD thesis.
  66. %% 
  67. %% PROCEEDINGS -- The proceedings of a conference.
  68. %% 
  69. %% TECHREPORT -- A report published by a school or other institution,
  70. %% usually numbered within a series.
  71. %% 
  72. %% UNPUBLISHED -- A document having an author and title, but not formally
  73. %% published.
  74.  
  75. ENTRY
  76.   { address
  77.     author
  78.     booktitle
  79.     chapter
  80.     edition
  81.     editor
  82.     howpublished
  83.     institution
  84.     journal
  85.     key
  86.     language
  87.     month
  88.     note
  89.     number
  90.     organization
  91.     pages
  92.     publisher
  93.     school
  94.     series
  95.     title
  96.     type
  97.     volume
  98.     year
  99.   }
  100.   {}
  101.   { label extra.label }
  102.  
  103. % Removed after.sentence, after.block---not needed.
  104.  
  105. INTEGERS { output.state before.all mid.sentence }
  106.  
  107. FUNCTION {init.state.consts}
  108. { #0 'before.all :=
  109.   #1 'mid.sentence :=
  110. }
  111.  
  112. % Scratch variables:
  113.  
  114. STRINGS { s t }
  115.  
  116. % Utility functions
  117.  
  118. FUNCTION {shows}
  119. { duplicate$ "::::  `" swap$ * "'" * top$
  120. }
  121.  
  122. FUNCTION {not}
  123. {   { #0 }
  124.     { #1 }
  125.   if$
  126. }
  127.  
  128. FUNCTION {and}
  129. {   'skip$
  130.     { pop$ #0 }
  131.   if$
  132. }
  133.  
  134. FUNCTION {or}
  135. {   { pop$ #1 }
  136.     'skip$
  137.   if$
  138. }
  139.  
  140. FUNCTION {field.or.null}
  141. { duplicate$ empty$
  142.     { pop$ "" }
  143.     'skip$
  144.   if$
  145. }
  146.  
  147. FUNCTION {emphasize}
  148. { duplicate$ empty$
  149.     { pop$ "" }
  150.     { "{\em " swap$ * "}" * }
  151.   if$
  152. }
  153.  
  154. % n.dashify is used to make sure page ranges get the TeX code
  155. % (two hyphens) for en-dashes.
  156.  
  157. FUNCTION {n.dashify}
  158. { 't :=
  159.   ""
  160.     { t empty$ not }
  161.     { t #1 #1 substring$ "-" =
  162.     { t #1 #2 substring$ "--" = not
  163.         { "--" *
  164.           t #2 global.max$ substring$ 't :=
  165.         }
  166.         {   { t #1 #1 substring$ "-" = }
  167.         { "-" *
  168.           t #2 global.max$ substring$ 't :=
  169.         }
  170.           while$
  171.         }
  172.       if$
  173.     }
  174.     { t #1 #1 substring$ *
  175.       t #2 global.max$ substring$ 't :=
  176.     }
  177.       if$
  178.     }
  179.   while$
  180. }
  181.  
  182. % tie.or.space.connect connects two items with a ~ if the
  183. % second item is less than 3 letters long, otherwise it just puts an 
  184. % ordinary space.
  185.  
  186. FUNCTION {tie.or.space.connect}
  187. { duplicate$ text.length$ #3 <
  188.     { "~" }
  189.     { " " }
  190.   if$
  191.   swap$ * *
  192. }
  193.  
  194. FUNCTION {add.space.if.necessary}
  195. { duplicate$ "" =
  196.     'skip$
  197.     { " " * }
  198.   if$
  199. }
  200.  
  201. % either.or.check gives a warning if two mutually exclusive fields
  202. % were used in the database.
  203.  
  204. FUNCTION {either.or.check}
  205. { empty$
  206.     'pop$
  207.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  208.   if$
  209. }
  210.  
  211. % output.nonnull is called by output.
  212.  
  213. FUNCTION {output.nonnull}
  214. % remove the top item from the stack because it's in the way.
  215. { 's := 
  216.   output.state mid.sentence =
  217. % If we're in mid-sentence, add a comma to the new top item and write it
  218.     { ", " * write$ } 
  219. % Otherwise, if we're at the beginning of a bibitem,
  220.     { output.state before.all =
  221. % just write out the top item from the stack;
  222.       'write$
  223. % and the last alternative is that we're at the end of the current
  224. % bibitem, so we add a period to the top stack item and write it out.
  225.         { add.period$ " " * write$ }
  226.       if$
  227.       mid.sentence 'output.state :=
  228.     }
  229.   if$
  230. % Put the top item back on the stack that we removed earlier.
  231.   s
  232. }
  233.  
  234. % Output checks to see if the stack top is empty; if not, it
  235. % calls output.nonnull to write it out.
  236.  
  237. FUNCTION {output}
  238. { duplicate$ empty$
  239.     'pop$
  240.     'output.nonnull
  241.   if$
  242. }
  243.  
  244. % Output.check is like output except that it gives a warning on-screen
  245. % if the given field in the database entry is empty.  t is the field
  246. % name.
  247.  
  248. FUNCTION {output.check}
  249. { 't :=
  250.   duplicate$ empty$
  251.     { pop$ "empty " t * " in " * cite$ * warning$ }
  252.     'output.nonnull
  253.   if$
  254. }
  255.  
  256. FUNCTION {output.bibitem}
  257. { newline$
  258.   "\bibitem{" write$
  259.   cite$ write$
  260.   "}" write$
  261.   newline$
  262. % This empty string is the first thing that will be written
  263. % the next time write$ is called.  Done this way because each
  264. % item is saved on the stack until we find out what punctuation
  265. % should be added after it.  Therefore we need an empty first item.
  266.   ""
  267.   before.all 'output.state :=
  268. }
  269.  
  270. FUNCTION {fin.entry}
  271. { add.period$
  272.   write$
  273.   newline$
  274. }
  275.  
  276. % Removed new.block, new.block.checka, new.block.checkb, new.sentence,
  277. % new.sentence.checka, and new.sentence.checkb functions here, since they
  278. % don't seem to be needed in the AMS style.  Also moved some real
  279. % basic functions like `and' and 'or' earlier in the file.
  280.  
  281. INTEGERS { nameptr namesleft numnames }
  282.  
  283. % The extra section to write out a language field was added
  284. % for AMSPLAIN.BST.  Not present in plain.bst.
  285.  
  286. FUNCTION {format.language}
  287. { language empty$
  288.     { "" }
  289.     { " (" language * ")" * }
  290.   if$
  291. }
  292.  
  293. % This version of format.names puts names in the format
  294. %
  295. % First von Last, Jr.
  296. %
  297. % (i.e., first name first, no abbreviating to initials).
  298.  
  299. FUNCTION {format.names}
  300. { 's :=
  301.   #1 'nameptr :=
  302.   s num.names$ 'numnames :=
  303.   numnames 'namesleft :=
  304.     { namesleft #0 > }
  305.     { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
  306.       nameptr #1 >
  307.     { namesleft #1 >
  308.         { ", " * t * }
  309.         { numnames #2 >
  310.         { "," * }
  311.         'skip$
  312.           if$
  313.           t "others" =
  314.         { " et~al." * }
  315.         { " and " * t * }
  316.           if$
  317.         }
  318.       if$
  319.     }
  320.     't
  321.       if$
  322.       nameptr #1 + 'nameptr :=
  323.       namesleft #1 - 'namesleft :=
  324.     }
  325.   while$
  326. }
  327.  
  328. FUNCTION {format.authors}
  329. { author empty$
  330.     { "" }
  331.     { extra.label "\bysame" =
  332.          {"\bysame"}
  333.          { author format.names }
  334.      if$
  335.     }
  336.   if$
  337. }
  338.  
  339. FUNCTION {format.editors}
  340. { editor empty$
  341.     { "" }
  342.     { editor format.names
  343.       editor num.names$ #1 >
  344.     { " (eds.)" * }
  345.     { " (ed.)" * }
  346.       if$
  347.     }
  348.   if$
  349. }
  350.  
  351. FUNCTION {format.nonauthor.editors}
  352. { editor empty$
  353.     { "" }
  354.     { editor format.names
  355.       editor num.names$ #1 >
  356.     { ", eds." * }
  357.     { ", ed." * }
  358.       if$
  359.     }
  360.   if$
  361. }
  362.  
  363. FUNCTION {format.title}
  364. { title empty$
  365.     { "" }
  366.     { title "t" change.case$ emphasize }
  367.   if$
  368. }
  369.  
  370. FUNCTION {format.journal.vol.year}
  371. { journal empty$
  372.     { "journal name missing in " cite$ * warning$ }
  373.     { journal
  374.       volume empty$ 
  375.         'skip$
  376.         { " {\bf " * volume * "}" * }
  377.       if$
  378.       year empty$
  379.         { "year missing in " cite$ * warning$ }
  380.         { " (" * year * ")" * }
  381.       if$
  382.     }
  383.   if$
  384. }
  385.  
  386. % For formatting the issue number for a journal article.
  387.  
  388. FUNCTION {format.number}
  389. { number empty$
  390.     { "" }
  391.     { "no.~" number * }
  392.   if$
  393. }
  394.  
  395. % For formatting miscellaneous dates
  396.  
  397. FUNCTION {format.date}
  398. { year empty$
  399.     { month empty$
  400.     { "" }
  401.     { "there's a month but no year in " cite$ * warning$
  402.       month
  403.     }
  404.       if$
  405.     }
  406.     { month empty$
  407.     'year
  408.     { month " " * year * }
  409.       if$
  410.     }
  411.   if$
  412. }
  413.  
  414. %%      The volume, series and number information is sort of tricky.
  415. %%      This code handles it as follows:
  416. %%      If the series is present, and the volume, but not the number,
  417. %%        then we do "{\em Book title}, Series Name, vol. 000"
  418. %%      If the series is present, and the number, but not the volume,
  419. %%        then we do "{\em Book title}, Series Name, no. 000"
  420. %%      If the series is present, and both number and volume,
  421. %%        then we do "{\em Book title}, vol. XX, Series Name, no. 000"
  422. %%      Finally, if the series is absent, 
  423. %%        then we do "{\em Book title}, vol. XX"
  424. %%        or         "{\em Book title}, no. 000"
  425. %%        and if both volume and number are present, give a warning message.
  426.  
  427. FUNCTION {format.bookvolume.series.number}
  428. { volume empty$
  429.     { "" % Push the empty string as a placeholder in case everything else
  430.          % is empty too.
  431.       series empty$
  432.         'skip$
  433.         { series } % if series is not empty put in stack
  434.       if$
  435.       number empty$
  436.         'skip$
  437.         { duplicate$ empty$ % if no preceding material,
  438.             'skip$          % do nothing, otherwise
  439.             { ", " * }      % add a comma and space to separate.
  440.           if$ 
  441.           "no." number tie.or.space.connect * % add the number information
  442.         }
  443.       if$
  444.     }
  445. %% If the volume is NOT EMPTY:
  446.     { "vol." volume tie.or.space.connect % vol. XX
  447.       number empty$
  448.         { series empty$
  449.             'skip$
  450.             { series ", " * swap$ *}    % Series Name, vol. XX
  451.           if$
  452.         }
  453.         { series empty$
  454.             { "can't use both volume and number if series info is missing" 
  455.               warning$
  456.               "in BibTeX entry type `" type$ * "'" * top$ 
  457.             }
  458.             { ", " * series * ", no." * number tie.or.space.connect }
  459.           if$
  460.         }
  461.       if$
  462.     }
  463.   if$
  464.  
  465. }  % end of format.bookvolume.series.number
  466.  
  467. %% format.inproc.title.where.editors is
  468. %% used by inproceedings and incollection entry types
  469.  
  470. FUNCTION {format.inproc.title.address.editors}
  471. { booktitle empty$
  472.     { "" }
  473. %%      No case changing or emphasizing for the title.  We want initial
  474. %%      caps, roman.
  475.     { booktitle } 
  476.   if$
  477. %%      We add parentheses around the address (place where conference
  478. %%      was held).
  479.   address empty$
  480.     'skip$
  481.     { add.space.if.necessary "(" * address * ")" * }
  482.   if$
  483. %%      Likewise we add parentheses around the editors' names.
  484.   editor empty$
  485.     'skip$
  486.     { add.space.if.necessary "(" * format.nonauthor.editors * ")" * }
  487.   if$
  488. }
  489.  
  490. % Desired output:
  491. %
  492. % Lecture Notes in Math., no.~1224
  493.  
  494. FUNCTION {format.number.series}
  495. { series empty$
  496.     { number empty$
  497.         { "" }
  498.         { "there's a number but no series in " cite$ * warning$ }
  499.       if$
  500.     }
  501.     { series 
  502.       number empty$
  503.         'skip$
  504.         { ", no.~" * number * }
  505.       if$
  506.     }
  507.   if$
  508. }
  509.  
  510. FUNCTION {format.edition}
  511. { edition empty$
  512.     { "" }
  513.     { output.state mid.sentence =
  514.     { edition "l" change.case$ " ed." * }
  515.     { edition "t" change.case$ " ed." * }
  516.       if$
  517.     }
  518.   if$
  519. }
  520.  
  521. INTEGERS { multiresult }
  522.  
  523. FUNCTION {multi.page.check}
  524. { 't :=
  525.   #0 'multiresult :=
  526.     { multiresult not
  527.       t empty$ not
  528.       and
  529.     }
  530.     { t #1 #1 substring$
  531.       duplicate$ "-" =
  532.       swap$ duplicate$ "," =
  533.       swap$ "+" =
  534.       or or
  535.     { #1 'multiresult := }
  536.     { t #2 global.max$ substring$ 't := }
  537.       if$
  538.     }
  539.   while$
  540.   multiresult
  541. }
  542.  
  543. FUNCTION {format.pages}
  544. { pages empty$
  545.     { "" }
  546.     { pages n.dashify }
  547.   if$
  548. }
  549.  
  550. FUNCTION {format.book.pages}
  551. { pages empty$
  552.     { "" }
  553.     { pages multi.page.check
  554.     { "pp.~" pages n.dashify * }
  555.     { "p.~" pages * }
  556.       if$
  557.     }
  558.   if$
  559. }
  560.  
  561. FUNCTION {format.chapter.pages}
  562. { chapter empty$
  563.     'format.pages
  564.     { type empty$
  565.     { "ch.~" }
  566.     { type "l" change.case$ " " * }
  567.       if$
  568.       chapter *
  569.       pages empty$
  570.     'skip$
  571.     { ", " * format.book.pages * }
  572.       if$
  573.     }
  574.   if$
  575. }
  576.  
  577. FUNCTION {empty.misc.check}
  578. { author empty$ title empty$ howpublished empty$
  579.   month empty$ year empty$ note empty$
  580.   and and and and and
  581.   key empty$ not and
  582.     { "all relevant fields are empty in " cite$ * warning$ }
  583.     'skip$
  584.   if$
  585. }
  586.  
  587. FUNCTION {format.thesis.type}
  588. { type empty$
  589.     'skip$
  590.     { pop$
  591.       type "t" change.case$
  592.     }
  593.   if$
  594. }
  595.  
  596. FUNCTION {format.tr.number}
  597. { type empty$
  598.     { "Tech. Report" }
  599.     'type
  600.   if$
  601.   number empty$
  602.     { "t" change.case$ }
  603.     { number tie.or.space.connect }
  604.   if$
  605. }
  606.  
  607. % The format.crossref functions haven't been paid much attention
  608. % at the present time (June 1990) and could probably use some
  609. % work.  MJD
  610.  
  611. FUNCTION {format.article.crossref}
  612. { key empty$
  613.     { journal empty$
  614.     { "need key or journal for " cite$ * " to crossref " * crossref *
  615.       warning$
  616.       ""
  617.     }
  618.     { "In " journal * }
  619.       if$
  620.     }
  621.     { "In " key * }
  622.   if$
  623.   " \cite{" * crossref * "}" *
  624. }
  625.  
  626. FUNCTION {format.crossref.editor}
  627. { editor #1 "{vv~}{ll}" format.name$
  628.   editor num.names$ duplicate$
  629.   #2 >
  630.     { pop$ " et~al." * }
  631.     { #2 <
  632.     'skip$
  633.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  634.         { " et~al." * }
  635.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  636.       if$
  637.     }
  638.       if$
  639.     }
  640.   if$
  641. }
  642.  
  643. FUNCTION {format.book.crossref}
  644. { volume empty$
  645.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  646.       "In "
  647.     }
  648.     { "Vol." volume tie.or.space.connect
  649.       " of " *
  650.     }
  651.   if$
  652.   editor empty$
  653.   editor field.or.null author field.or.null =
  654.   or
  655.     { key empty$
  656.     { series empty$
  657.         { "need editor, key, or series for " cite$ * " to crossref " *
  658.           crossref * warning$
  659.           "" *
  660.         }
  661.         { series * }
  662.       if$
  663.     }
  664.     { key * }
  665.       if$
  666.     }
  667.     { format.crossref.editor * }
  668.   if$
  669.   " \cite{" * crossref * "}" *
  670. }
  671.  
  672. FUNCTION {format.incoll.inproc.crossref}
  673. { editor empty$
  674.   editor field.or.null author field.or.null =
  675.   or
  676.     { key empty$
  677.     { booktitle empty$
  678.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  679.           crossref * warning$
  680.           ""
  681.         }
  682.         { "In {\em " booktitle * "\/}" * }
  683.       if$
  684.     }
  685.     { "In " key * }
  686.       if$
  687.     }
  688.     { "In " format.crossref.editor * }
  689.   if$
  690.   " \cite{" * crossref * "}" *
  691. }
  692.  
  693. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  694.  
  695. % The main functions for each entry type.
  696.  
  697. % journal, vol and year are formatted together because they are
  698. % not separated by commas.
  699.  
  700. FUNCTION {article}
  701. { output.bibitem
  702.   format.authors "author" output.check
  703.   format.title "title" output.check
  704.   crossref missing$
  705.     { format.journal.vol.year "journal, volume, and year" output.check
  706.       format.number output
  707.       format.pages "pages" output.check
  708.     }
  709.     { format.article.crossref output.nonnull
  710.       format.pages output
  711.     }
  712.   if$
  713.   format.language *
  714.   note output
  715.   fin.entry
  716. }
  717.  
  718. FUNCTION {book}
  719. { output.bibitem
  720.   author empty$
  721.     { format.editors "author and editor" output.check }
  722.     { format.authors output.nonnull
  723.       crossref missing$
  724.     { "author and editor" editor either.or.check }
  725.     'skip$
  726.       if$
  727.     }
  728.   if$
  729.   format.title "title" output.check
  730.   format.edition output
  731.   crossref missing$
  732.     { format.bookvolume.series.number output
  733.       publisher "publisher" output.check
  734.       address output
  735.     }
  736.     { format.book.crossref output.nonnull
  737.     }
  738.   if$
  739.   format.date "year" output.check
  740.   format.language *
  741.   note output
  742.   fin.entry
  743. }
  744.  
  745. FUNCTION {booklet}
  746. { output.bibitem
  747.   format.authors output
  748.   format.title "title" output.check
  749.   howpublished output
  750.   address output
  751.   format.date output
  752.   note output
  753.   fin.entry
  754. }
  755.  
  756. FUNCTION {inbook}
  757. { output.bibitem
  758.   author empty$
  759.     { format.editors "author and editor" output.check }
  760.     { format.authors output.nonnull
  761.       crossref missing$
  762.     { "author and editor" editor either.or.check }
  763.     'skip$
  764.       if$
  765.     }
  766.   if$
  767.   title "title" output.check
  768.   crossref missing$
  769.     { format.bookvolume.series.number output
  770.       format.chapter.pages "chapter and pages" output.check
  771.       format.number.series output
  772.       publisher "publisher" output.check
  773.       address output
  774.     }
  775.     { format.chapter.pages "chapter and pages" output.check
  776.       format.book.crossref output.nonnull
  777.     }
  778.   if$
  779.   format.edition output
  780.   format.date "year" output.check
  781.   format.book.pages output
  782.   format.language *
  783.   note output
  784.   fin.entry
  785. }
  786.  
  787. FUNCTION {showstack}
  788. {"STACK====================================================================="
  789. top$
  790. stack$
  791. "ENDSTACK=================================================================="
  792. top$
  793. }
  794.  
  795. FUNCTION {incollection}
  796. { output.bibitem
  797.   format.authors "author" output.check
  798.   format.title "title" output.check
  799.   crossref missing$
  800.     { format.inproc.title.address.editors "booktitle" output.check
  801.       format.bookvolume.series.number output
  802.       publisher "publisher" output.check
  803.       address output
  804.       format.edition output
  805.       format.date "year" output.check
  806.     }
  807.     { format.incoll.inproc.crossref output.nonnull
  808.     }
  809.   if$
  810.   note output
  811.   format.book.pages output
  812.   format.language *
  813.   fin.entry
  814. }
  815.  
  816. FUNCTION {inproceedings}
  817. { output.bibitem
  818.   format.authors "author" output.check
  819.   format.title "title" output.check
  820.   crossref missing$
  821.     { format.inproc.title.address.editors "booktitle" output.check
  822.       format.bookvolume.series.number output
  823.       organization output
  824.       publisher output
  825.       format.date "year" output.check
  826.     }
  827.     { format.incoll.inproc.crossref output.nonnull
  828.     }
  829.   if$
  830.   note output
  831.   format.book.pages output
  832.   format.language *
  833.   fin.entry
  834. }
  835.  
  836. FUNCTION {conference} { inproceedings }
  837.  
  838. FUNCTION {manual}
  839. { output.bibitem
  840.   author empty$
  841.     { organization empty$
  842.     'skip$
  843.     { organization output.nonnull
  844.       address output
  845.     }
  846.       if$
  847.     }
  848.     { format.authors output.nonnull }
  849.   if$
  850.   format.title "title" output.check
  851.   author empty$
  852.     { organization empty$
  853.     { address output }
  854.     'skip$
  855.       if$
  856.     }
  857.     { organization output
  858.       address output
  859.     }
  860.   if$
  861.   format.edition output
  862.   format.date output
  863.   note output
  864.   fin.entry
  865. }
  866.  
  867. FUNCTION {mastersthesis}
  868. { output.bibitem
  869.   format.authors "author" output.check
  870.   format.title "title" output.check
  871.   "Master's thesis" format.thesis.type output.nonnull
  872.   school "school" output.check
  873.   address output
  874.   format.date "year" output.check
  875.   note output
  876.   fin.entry
  877. }
  878.  
  879. FUNCTION {misc}
  880. { output.bibitem
  881.   format.authors output
  882.   format.title output
  883.   howpublished output
  884.   format.date output
  885.   note output
  886.   format.book.pages output
  887.   fin.entry
  888.   empty.misc.check
  889. }
  890.  
  891. FUNCTION {phdthesis}
  892. { output.bibitem
  893.   format.authors "author" output.check
  894.   format.title "title" output.check
  895.   "Ph.D. thesis" format.thesis.type output.nonnull
  896.   school "school" output.check
  897.   address output
  898.   format.date "year" output.check
  899.   note output
  900.   format.book.pages output
  901.   fin.entry
  902. }
  903.  
  904. FUNCTION {proceedings}
  905. { output.bibitem
  906.   editor empty$
  907.     { organization output }
  908.     { format.editors output.nonnull }
  909.   if$
  910.   format.title "title" output.check
  911.   format.bookvolume.series.number output
  912.   address empty$
  913.     { editor empty$
  914.         'skip$
  915.     { organization output }
  916.       if$
  917.       publisher output
  918.       format.date "year" output.check
  919.     }
  920.     { address output.nonnull
  921.       editor empty$
  922.     'skip$
  923.     { organization output }
  924.       if$
  925.       publisher output
  926.       format.date "year" output.check
  927.     }
  928.   if$
  929.   note output
  930.   fin.entry
  931. }
  932.  
  933. FUNCTION {techreport}
  934. { output.bibitem
  935.   format.authors "author" output.check
  936.   format.title "title" output.check
  937.   format.tr.number output.nonnull
  938.   institution "institution" output.check
  939.   address output
  940.   format.date "year" output.check
  941.   note output
  942.   fin.entry
  943. }
  944.  
  945. FUNCTION {unpublished}
  946. { output.bibitem
  947.   format.authors "author" output.check
  948.   format.title "title" output.check
  949.   note "note" output.check
  950.   format.date output
  951.   fin.entry
  952. }
  953.  
  954. FUNCTION {default.type} { misc }
  955.  
  956. MACRO {jan} {"January"}
  957.  
  958. MACRO {feb} {"February"}
  959.  
  960. MACRO {mar} {"March"}
  961.  
  962. MACRO {apr} {"April"}
  963.  
  964. MACRO {may} {"May"}
  965.  
  966. MACRO {jun} {"June"}
  967.  
  968. MACRO {jul} {"July"}
  969.  
  970. MACRO {aug} {"August"}
  971.  
  972. MACRO {sep} {"September"}
  973.  
  974. MACRO {oct} {"October"}
  975.  
  976. MACRO {nov} {"November"}
  977.  
  978. MACRO {dec} {"December"}
  979.  
  980. READ
  981.  
  982. FUNCTION {sortify}
  983. { purify$
  984.   "l" change.case$
  985. }
  986.  
  987. INTEGERS { len }
  988.  
  989. FUNCTION {chop.word}
  990. { 's :=
  991.   'len :=
  992.   s #1 len substring$ =
  993.     { s len #1 + global.max$ substring$ }
  994.     's
  995.   if$
  996. }
  997.  
  998. FUNCTION {sort.format.names}
  999. { 's :=
  1000.   #1 'nameptr :=
  1001.   ""
  1002.   s num.names$ 'numnames :=
  1003.   numnames 'namesleft :=
  1004.     { namesleft #0 > }
  1005.     { nameptr #1 >
  1006.     { "   " * }
  1007.     'skip$
  1008.       if$
  1009.       s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
  1010.       nameptr numnames = t "others" = and
  1011.     { "et al" * }
  1012.     { t sortify * }
  1013.       if$
  1014.       nameptr #1 + 'nameptr :=
  1015.       namesleft #1 - 'namesleft :=
  1016.     }
  1017.   while$
  1018. }
  1019.  
  1020. FUNCTION {sort.format.title}
  1021. { 't :=
  1022.   "A " #2
  1023.     "An " #3
  1024.       "The " #4 t chop.word
  1025.     chop.word
  1026.   chop.word
  1027.   sortify
  1028.   #1 global.max$ substring$
  1029. }
  1030.  
  1031. FUNCTION {author.sort}
  1032. { author empty$
  1033.     { key empty$
  1034.     { "to sort, need author or key in " cite$ * warning$
  1035.       ""
  1036.     }
  1037.     { key sortify }
  1038.       if$
  1039.     }
  1040.     { author sort.format.names }
  1041.   if$
  1042. }
  1043.  
  1044. FUNCTION {author.editor.sort}
  1045. { author empty$
  1046.     { editor empty$
  1047.     { key empty$
  1048.         { "to sort, need author, editor, or key in " cite$ * warning$
  1049.           ""
  1050.         }
  1051.         { key sortify }
  1052.       if$
  1053.     }
  1054.     { editor sort.format.names }
  1055.       if$
  1056.     }
  1057.     { author sort.format.names }
  1058.   if$
  1059. }
  1060.  
  1061. FUNCTION {author.organization.sort}
  1062. { author empty$
  1063.     { organization empty$
  1064.     { key empty$
  1065.         { "to sort, need author, organization, or key in " cite$ * warning$
  1066.           ""
  1067.         }
  1068.         { key sortify }
  1069.       if$
  1070.     }
  1071.     { "The " #4 organization chop.word sortify }
  1072.       if$
  1073.     }
  1074.     { author sort.format.names }
  1075.   if$
  1076. }
  1077.  
  1078. FUNCTION {editor.organization.sort}
  1079. { editor empty$
  1080.     { organization empty$
  1081.     { key empty$
  1082.         { "to sort, need editor, organization, or key in " cite$ * warning$
  1083.           ""
  1084.         }
  1085.         { key sortify }
  1086.       if$
  1087.     }
  1088.     { "The " #4 organization chop.word sortify }
  1089.       if$
  1090.     }
  1091.     { editor sort.format.names }
  1092.   if$
  1093. }
  1094.  
  1095. FUNCTION {presort}
  1096. { type$ "book" =
  1097.   type$ "inbook" =
  1098.   or
  1099.     'author.editor.sort
  1100.     { type$ "proceedings" =
  1101.     'editor.organization.sort
  1102.     { type$ "manual" =
  1103.         'author.organization.sort
  1104.         'author.sort
  1105.       if$
  1106.     }
  1107.       if$
  1108.     }
  1109.   if$
  1110.   "    "
  1111.   *
  1112.   year field.or.null sortify
  1113.   *
  1114.   "    "
  1115.   *
  1116.   title field.or.null
  1117.   sort.format.title
  1118.   *
  1119.   #1 entry.max$ substring$
  1120.   'sort.key$ :=
  1121. }
  1122.  
  1123. ITERATE {presort}
  1124.  
  1125. SORT
  1126.  
  1127. STRINGS { longest.label prev.author }
  1128.  
  1129. INTEGERS { number.label longest.label.width }
  1130.  
  1131. FUNCTION {initialize.longest.label}
  1132. { "" 'longest.label :=
  1133.   #1 'number.label :=
  1134.   #0 'longest.label.width :=
  1135.   "abcxyz" 'prev.author :=
  1136. }
  1137.  
  1138. FUNCTION {longest.label.pass}
  1139. { number.label int.to.str$ 'label :=
  1140.   number.label #1 + 'number.label :=
  1141.   label width$ longest.label.width >
  1142.     { label 'longest.label :=
  1143.       label width$ 'longest.label.width :=
  1144.     }
  1145.     'skip$
  1146.   if$
  1147.   author prev.author =
  1148.     { "\bysame" 'extra.label := }
  1149.     { "" 'extra.label :=
  1150.       author 'prev.author := 
  1151.     }
  1152.   if$
  1153. }
  1154.  
  1155. EXECUTE {initialize.longest.label}
  1156.  
  1157. ITERATE {longest.label.pass}
  1158.  
  1159. FUNCTION {begin.bib}
  1160. { preamble$ empty$
  1161.     'skip$
  1162.     { preamble$ write$ newline$ }
  1163.   if$
  1164.   "\ifx\undefined\bysame" write$ newline$
  1165.   "\newcommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\,}"
  1166.        write$ newline$
  1167.   "\fi" write$ newline$
  1168.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1169. }
  1170.  
  1171. EXECUTE {begin.bib}
  1172.  
  1173. EXECUTE {init.state.consts}
  1174.  
  1175. ITERATE {call.type$}
  1176.  
  1177. FUNCTION {end.bib}
  1178. { newline$
  1179.   "\end{thebibliography}" write$ newline$
  1180. }
  1181.  
  1182. EXECUTE {end.bib}
  1183. %% \CharacterTable
  1184. %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  1185. %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  1186. %%   Digits        \0\1\2\3\4\5\6\7\8\9
  1187. %%   Exclamation   \!     Double quote  \"     Hash (number) \#
  1188. %%   Dollar        \$     Percent       \%     Ampersand     \&
  1189. %%   Acute accent  \'     Left paren    \(     Right paren   \)
  1190. %%   Asterisk      \*     Plus          \+     Comma         \,
  1191. %%   Minus         \-     Point         \.     Solidus       \/
  1192. %%   Colon         \:     Semicolon     \;     Less than     \<
  1193. %%   Equals        \=     Greater than  \>     Question mark \?
  1194. %%   Commercial at \@     Left bracket  \[     Backslash     \\
  1195. %%   Right bracket \]     Circumflex    \^     Underscore    \_
  1196. %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
  1197. %%   Right brace   \}     Tilde         \~}
  1198.